#ifndef GRAPH_H
#define GRAPH_H

#include "gisgraph_global.h"
#include "vertex.h"
#include "edge.h"

#include <QGraphicsScene>

class GISGRAPHSHARED_EXPORT Graph : public QGraphicsScene
{
public:
	Graph(const QRectF &r = QRectF(-500, -300, 1000, 600), QObject *parent = 0);
	void addVertex(Vertex *v);
	void addEdge(Edge *g);
	QList<Vertex *> vertices(const Vertex *v = 0) const;
	QList<Edge *> edges(const Vertex *v = 0) const;
	Edge* edge(Vertex *u, Vertex* v);
private:
	QHash<Vertex *, QList<Edge *> > m_adjacencyMap;
};

class GISGRAPHSHARED_EXPORT GraphFactory
{
public:
	GraphFactory() : currentName(0) { resetNameGenerator(); }
	Graph *createGraph(int vertex_no, int lvl = 0);
	void fillGraph(Graph* g);
private:
	QString generateName();
	void resetNameGenerator();
private:
	char *currentName;
};

#endif // GRAPH_H
